var e = require("./api.js"), o = require("./disapi.js");

require("./common.js"), getApp();

module.exports = {
    is_getUser: function(e) {
        wx.getSetting({
            success: function(o) {
                void 0 != o.authSetting["scope.userInfo"] ? e.setData({
                    authorize: !1
                }) : e.setData({
                    authorize: !0
                }), console.log(e.data.authorize);
            }
        });
    },
    bindGetUserInfo: function(t, n) {
        if (console.log(t.detail.userInfo), t.detail.userInfo) {
            var i = "";
            wx.getStorage({
                key: "pid",
                success: function(e) {
                    if (console.log(e.data), i = e.data, console.log(i), "" != i && void 0 != i) {
                        var t = wx.getStorageSync("openid");
                        o.check_user({
                            openid: t
                        }).then(function(e) {
                            0 == e.errno && (e.data ? o.get_group_bing({
                                openid: t,
                                pid: i
                            }) : (o.get_group_bing({
                                openid: t,
                                pid: i
                            }), o.get_commoned_bing({
                                openid: t,
                                pid: i
                            })), wx.removeStorage({
                                key: "pid",
                                success: function(e) {
                                    console.log(e.data);
                                }
                            }));
                        });
                    }
                }
            });
            var a = {
                avatarUrl: t.detail.userInfo.avatarUrl,
                nickName: t.detail.userInfo.nickName,
                openid: wx.getStorageSync("openid"),
                sessionkey: wx.getStorageSync("sessionkey")
            };
            e.inserUserdata(a).then(function(e) {
                n.setData({
                    authorize: !1
                });
            });
        } else wx.showToast({
            title: "授权失败",
            icon: "none",
            duration: 2e3
        }), n.setData({
            authorize: !0
        });
    }
};